const API = require("../../common/constant.js");
const util = require("../../utils/util");
var app = getApp();
Page({
  data: {
    pageIndex: 1,
    pageCount: 0,
    noticeType: 'invitedinner',
    noticeArr: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  linkToPage: function(e) {
    let index = e.currentTarget.dataset.num;
    let infos = this.data.noticeArr[index];
    wx.navigateTo({
      url: `../noticeInfos/noticeInfos?infos=${JSON.stringify(infos)}`,
    })
  },
  getFanNotic() {
    util.http({
      url: API.URL.MESSAGE.FIND_MESSAGENOTICEBYPAGE,
      data: {
        pageIndex: this.data.pageIndex,
        pageSize: 9,
        noticeType: 'invitedinner'
      },
      success: (res) => {
        console.log(res);
        this.setData({
          noticeArr: this.data.noticeArr.concat(res.data.bussData),
          pageCount: res.data.pageCount
        })
      },
      fail: (res) => {
        console.log(res);
      }
    })
  },
  onLoad: function (options) {
    this.getFanNotic();
  },
  onReachBottom() {
    if (this.data.pageCount <= this.data.pageIndex) return
    this.setData({
      pageIndex: this.data.pageIndex + 1
    })
    this.getFanNotic();
  },
})